#include <iterator>
#include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <string>
#include <cctype>
#include "lib\functions.h"
using namespace std;

vector<string> GetStopWords();
void RemoveStopWords(ifstream &, ofstream &, vector<string>);

int main(int argc, char * argv[])
{
    vector<string> name = GetStopWords();
    ifstream fin(argv[1], ios::binary);
    ofstream fout("stpwrds_output.txt", ios::binary);
    string token;
    RemoveStopWords(fin, fout, name);
}

void RemoveStopWords(ifstream &fin, ofstream &fout, vector<string> name)
{
    string token;
    while((token = GetNextToken(fin, fout)) !="" )
    {
        bool flag=0;
        for(vector<string>::iterator iter=name.begin(); iter != name.end(); iter++)
        {
            if (*(iter) == token)
            {
                flag=1;
            }
        }
        if (!flag)
        {
            fout<<token;
        }
    }

}

vector<string> GetStopWords()
{
    vector<string> names;
    ifstream fin("stopwords.txt");
    string token;

    while((token=GetNextToken(fin))!="" )
    {
        names.push_back(token);
    }
    return names;
}
